home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 217 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  4.4 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c,comp.std.c
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. Date: 29 Jan 1996 16:05:18 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan29090518@qcd.lanl.gov>
  8. References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM>
  9.     <KANZE.96Jan26164833@gabi.gabi-soft.fr> <DLtABq.Fzu@mv.mv.com>
  10.     <4edqh2$rvl@solutions.solon.com>
  11.     <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  12. NNTP-Posting-Host: qcd.lanl.gov
  13. Mime-Version: 1.0
  14. Content-Type: text
  15. In-reply-to: kanze@lts.sel.alcatel.de's message of 29 Jan 1996 11:19:56 GMT
  16.  
  17. In article <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  18. kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes: 
  19. <snip>
  20.    I think the crux of Michael Furman's question lies therein.  Does the
  21.    standard require a diagnostic if the function main is not of one of
  22.    the two types given?
  23.  
  24. No diagnostic is _required_, but irrespective of whether a diagnostic
  25. is produced, there is no guarantee how the program will behave. This
  26. is a quintessential example of undefined behaviour. An implementation
  27. is free to define whatever meaning it chooses for this, exactly as it
  28. is free to change the meaning of the entire rest of the program based
  29. on this one statement.
  30.  
  31.    To tell the truth, I'm not sure what the answer is.  The text
  32.    concerning main is in the chapter describing the environment.  It
  33.    doesn't appear as a semantic restriction or anything.  It simply
  34.    states that on start-up, a function called main will be called, and
  35.    that the implementation must support the following forms.  It doesn't
  36.    seem (to me, at least) to say anything about what other forms it might
  37.    support, or what the implementation must do if given a fully other
  38.    definition of main.
  39.  
  40. And hence, it is an undefined behaviour.
  41.  
  42.    Normally, I would expect (at the very least) a compiler to generate a
  43.    warning or an error for a main that it did not support.  In fact,
  44.    however, my compiler (gcc) accepts the following definition without
  45.    the slightest complaint, although I'd rather not think about what will
  46.    happen when I access parameter d:
  47.  
  48.        int main( char a , int b , long c , double d )
  49.  
  50. Undefined behaviour does not need diagnostic.
  51.  
  52.    |> For purposes of the C newsgroups, discussion of what is/isn't legal
  53.    |> is generally restricted to strictly conforming C.
  54.  
  55.    Yes and no.  In comp.std.c, the discussion is exactly about what is
  56.    legal according to the standard.  In comp.lang.c (to which this
  57.    article is also cross-posted), the discussion should generally be a
  58.    bit more open.
  59.  
  60.    Thus, for example, in comp.std.c, a program with a variable named far
  61.    is illegal, and that is it.  In comp.lang.c (and I hope in its
  62.  
  63. Huh? A variable named far is perfectly legal.
  64.  
  65.    moderated variant), I would hope that someone would point out that,
  66.    legal or not, it's going to get you into trouble.
  67.  
  68. I hope that situation changes soon in the future. Implementation
  69. extensions must not encroach upon user name space: the C standard
  70. attempts to formalize the distinction between user and implementation
  71. name spaces: compilers ought to follow it. Not only in law, but also
  72. in spirit.
  73.  
  74. For example, assuming that the concept of a far pointer is truly
  75. required (It is really an exceptional circumstance which truly
  76. _requires_ it; a compiler should usually figure out whether a near or
  77. far pointer will work better: but that is a separate discussion), a
  78. compiler should invent a keyword in the implementation name space
  79. (e.g. __far) for it. It may provide a non-default switch
  80. /backward-compatible to allow it to recognize far as a keyword and
  81. treat it as a syntax error if used as a variable name.
  82.  
  83. But I agree that discussions in comp.lang.c should also take care of
  84. current realities, even if those realities are fossils of an era long
  85. past, frozen in time only by the arrogant ignorance of a large body of
  86. users with a narrow view to the future.
  87.  
  88. Cheers
  89. Tanmoy
  90. --
  91. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  92. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  93. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  94. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  95. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  96. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  97.